<template>
  <div class="personinfomng-container">
    <div class="page-title">
      <svg class="icon icon-zhibanguanli" aria-hidden="true">
        <use xlink:href="#icon-zhibanguanli"/>
      </svg>
      <span>停车场管理</span>
      <pagego :path="personinfomngPath"/>
    </div>
    <div class="main-content">
      <div class="tool-bar">
        <!-- <el-pagination
          :current-page="currentPage4"
          :page-sizes="[100, 200, 300, 400]"
          :page-size="100"
          :total="400"
          layout=" prev, pager, next, sizes, total "
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/> -->
        <span style="font-size: 14px;">停车场</span>
        <el-select v-model="value" placeholder="请选择" size="small">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"/>
        </el-select>
        <div class="search-box">
          <span style="font-size: 14px;">姓名</span>
          <el-input
            v-model="searchText"
            size="small"
            clearable/>
          <span style="font-size: 14px;">联系方式</span>
          <el-input
            v-model="searchText"
            size="small"
            clearable/>
          <el-button size="small" type="primary" icon="el-icon-search">查询</el-button>
        </div>
      </div>
      <el-table
        :data="tableData"
        border
        stripe
        style="width: 100%">
        <!--<el-table-column
          type="selection"
          align="center"
          width="55"/>-->
        <el-table-column
          prop="id"
          label="序号"
          align="center"
          width="50"/>
        <el-table-column
          prop="name"
          label="姓名"/>
        <el-table-column
          prop="gender"
          label="性别"/>
        <el-table-column
          prop="contact"
          label="联系方式"/>
        <el-table-column
          prop="parking_lot"
          width="120"
          label="所属停车场"/>
        <el-table-column
          prop="post"
          width="120"
          label="岗位"/>
        <el-table-column
          prop="address"
          width="190"
          align="center"
          label="执行操作">
          <template slot-scope="scope">
            <el-button size="small" icon="el-icon-edit" @click="handleClick(scope.row)">编辑</el-button>
            <el-button size="small" type="danger" icon="el-icon-delete" @click="handleClickDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="tool-bar">
        <el-pagination
          :current-page="currentPage4"
          :page-sizes="[100, 200, 300, 400]"
          :page-size="100"
          :total="400"
          layout=" prev, pager, next, sizes, total "
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/>
      </div>
    </div>
    <el-dialog :visible.sync="dialogFormVisible" title="编辑信息" width="30%">
      <el-form :model="form">
        <el-form-item :label-width="formLabelWidth" label="姓名">
          <el-input v-model="form.name" size="small"/>
        </el-form-item>
        <el-form-item :label-width="formLabelWidth" label="性别">
          <el-input v-model="form.gender" size="small"/>
        </el-form-item>
        <el-form-item :label-width="formLabelWidth" label="联系方式">
          <el-input v-model="form.contact" size="small"/>
        </el-form-item>
        <el-form-item :label-width="formLabelWidth" label="所属停车场">
          <el-input v-model="form.parking_lot" size="small"/>
        </el-form-item>
        <el-form-item :label-width="formLabelWidth" label="岗位">
          <el-input v-model="form.post" size="small"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" size="small" @click="submitData">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { Message } from 'element-ui'
import Pagego from '@/components/pageGoBtn/index'

export default {
  name: 'Personinfomng',
  components: {
    Pagego
  },
  data () {
    return {
      radio: '1',
      value1: '',
      value: 'all',
      options: [{
        value: 'all',
        label: '全部'
      }, {
        value: '2',
        label: '停车场1'
      }, {
        value: '3',
        label: '停车场2'
      }, {
        value: '4',
        label: '停车场4'
      }, {
        value: '5',
        label: '停车场5'
      }],
      personinfomngPath: '/example/personinfomng',
      dialogFormVisible: false,
      form: {
        name: '',
        gender: '',
        contact: '',
        parking_lot: '',
        post: ''
      },
      formLabelWidth: '120px',
      currentPage4: 4,
      searchText: '',
      tableData: [{
        id: '1',
        name: '王天强',
        gender: '男',
        contact: '13658967458',
        parking_lot: '武昌停车场',
        post: '停车场管理员'
      },
      {
        id: '2',
        name: '王天强',
        gender: '男',
        contact: '13658967458',
        parking_lot: '武昌停车场',
        post: '停车场管理员'
      },
      {
        id: '3',
        name: '王天强',
        gender: '男',
        contact: '13658967458',
        parking_lot: '武昌停车场',
        post: '停车场管理员'
      },
      {
        id: '4',
        name: '王天强',
        gender: '男',
        contact: '13658967458',
        parking_lot: '武昌停车场',
        post: '停车场管理员'
      },
      {
        id: '5',
        name: '王天强',
        gender: '男',
        contact: '13658967458',
        parking_lot: '武昌停车场',
        post: '停车场管理员'
      },
      {
        id: '6',
        name: '王天强',
        gender: '男',
        contact: '13658967458',
        parking_lot: '武昌停车场',
        post: '停车场管理员'
      },
      {
        id: '7',
        name: '王天强',
        gender: '男',
        contact: '13658967458',
        parking_lot: '武昌停车场',
        post: '停车场管理员'
      },
      {
        id: '8',
        name: '王天强',
        gender: '男',
        contact: '13658967458',
        parking_lot: '武昌停车场',
        post: '停车场管理员'
      }]
    }
  },
  watch: {},
  methods: {
    handleClick (row) {
      console.log(row)
      this.dialogFormVisible = true
      this.form = row
    },
    handleClickDelete (row) {
      console.log(row.id)
      Message.success('删除成功～')
    },
    submitData () {
      this.dialogFormVisible = false
      Message.success('编辑成功～')
    },
    handleSizeChange (val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange (val) {
      console.log(`当前页: ${val}`)
    }
  }
}
</script>

<style lang="stylus" scoped>
.personinfomng-container{
  margin: 15px;
  color: #828282;
  font-size: 16px;
  background-color: #fff;
  padding-top: 0px;
  .status-span{
    color: #fff;
    display: inline-block;
    padding: 0px 10px;
    font-size: 12px;
  }
  .color-span-1{
    background-color: #5cb85c;
  }
  .color-span-2{
    background-color: #5bc0de;
  }
  .color-span-3{
    background-color: #f0ad4e;
  }
  .color-span-4{
    background-color: #d9534f;
  }
  .el-input{
    display: inline-block;
  }
  .page-title{
    width:100%;
    height: 44px;
    line-height: 44px;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 5px;
    padding: 0 15px;
    .icon{
      width: 22px;
      height: 22px;
      position: relative;
      top: 3px;
    }
  }
  .main-content{
    padding: 15px;
    padding-top: 0px;
    .tool-bar {
      padding: 10px 0px;
      position: relative;
      .search-box{
        position: absolute;
        right: 10px;
        top: 10px;
        .el-input{
          width: 120px;
        }
      }
    }
  }
}
</style>
